package com.chezai.client.global.device;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;

import com.chezai.client.bean.CheckTime;
import com.chezai.client.utils.CameraMgr;

import org.greenrobot.eventbus.EventBus;


/**
 * Describe 普通手机实现
 * Created by LZF on 2016/11/5.
 */
public class PhoneHardware extends DifferenceHardware {

//    @Override
//    public String getImei(Context context) {
//        return "355287000481188";
//    }

//    @Override
//    public String getImei(Context context, String prop, String defaultvalue) {
//        return "355287000481188";
//    }

    @Override
    public String getSerialNumber(Context context) {
        return "6010750";
    }

    @Override
    public String readIcCard(Context context) {
        return null;
    }

    @Override
    public void setCalibrateTime() {
        EventBus.getDefault().postSticky(new CheckTime(true));
    }

    @Override
    public void openSettings(Context context) {
        Intent intent = new Intent("/");
        ComponentName cm = new ComponentName("com.android.settings", "com.android.settings.Settings");
        intent.setComponent(cm);
        intent.setAction("android.intent.action.VIEW");
        context.startActivity(intent);
    }

    @Override
    public long getPowerTime() {
        return 0;
    }

    @Override
    public boolean cameraIsCanUse() {
        boolean isCanUse = CameraMgr.cameraIsCanUsed();
        return isCanUse;
    }

    @Override
    public boolean controlRelay(boolean open) {
        return false;
    }

    @Override
    public void installApk(Context context, String filePath) {
        Intent intentPath = new Intent(Intent.ACTION_VIEW);
        intentPath.setDataAndType(Uri.parse(filePath), "application/vnd.android.package-archive");
        intentPath.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intentPath);
    }

    @Override
    public void setAccPowerTime(Context context, long powerTime) {

    }

    @Override
    public void setScreenOrientation(Activity activity) {
        if (activity.getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
    }

    @Override
    public boolean isNeedRotaingImage() {
        return false;
    }

    @Override
    public void disableNotificationBar(Context context) {

    }

    @Override
    public void rebootDevice(Context context) {

    }

    @Override
    public void closeSerialPort() {
        
    }

    @Override
    public void readIDCard(Context context) {

    }


}
